﻿using System;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Windows.Forms;

namespace NExplorer.Core.Forms
{
    public sealed partial class StartWithCommandLineArgumentsForm : Form
    {
        private readonly FileSystemInfo _info;

        public StartWithCommandLineArgumentsForm()
        {
            InitializeComponent();

            Font = SystemFonts.DialogFont;

            _info = ServiceManager.Explorer.SelectedItems[0];
            string name = _info.Name;
            Text = "Start " + name;

            argumentsTextBox.Focus();
        }

        private void okButton_Click(object sender, EventArgs e)
        {
        	try
        	{
        		Process.Start(ServiceManager.Explorer.SelectedItems[0].FullName, argumentsTextBox.Text);
				DialogResult = DialogResult.OK;
			}
        	catch (Exception ex)
        	{
				MessageBox.Show("There was an error while trying to start:\n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
			}
        }
    }
}
